package com.qf.j2102.controller;

import com.qf.j2102.common.JsonBean;
import com.qf.j2102.po.SysCity;
import com.qf.j2102.service.SysCityService;
import com.qf.j2102.utils.JsonUtils;
import com.qf.j2102.vo.VCity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/city")
public class SysCityController {

    @Autowired
    private SysCityService cityService;

    @RequestMapping("/select.do")
    @ResponseBody
    public JsonBean selectAll(Integer pid){
        JsonBean bean = null;

        try {
            List<SysCity> list = cityService.selectAll(pid);
            bean = JsonUtils.createJsonBean(1,list);
        } catch (Exception e) {
            bean = JsonUtils.createJsonBean(0,e.getMessage());
        }
        return bean ;
    }

    @RequestMapping("/all.do")
    @ResponseBody
    public JsonBean selectAllInfo(){
        JsonBean bean = null;

        try {
            List<SysCity> list = cityService.selectAllInfo();
            bean = JsonUtils.createJsonBean(1,list);
        } catch (Exception e) {
            bean = JsonUtils.createJsonBean(0,e.getMessage());
        }
        return bean ;
    }


    @RequestMapping("/citys.do")
    @ResponseBody
    public JsonBean selectCitys(Integer getid, Integer backid){
        JsonBean bean = null;

        try {
            VCity vCity = cityService.selectCitys(getid, backid);
            bean = JsonUtils.createJsonBean(1,vCity);
        } catch (Exception e) {
            bean = JsonUtils.createJsonBean(0,e.getMessage());
        }
        return bean ;
    }


}
